Skip to content

Remove ihp-log package, use fast-logger directly#2600

Open
mpscholten wants to merge 4 commits intomasterfrom
remove-ihp-log
Open

Remove ihp-log package, use fast-logger directly#2600
mpscholten wants to merge 4 commits intomasterfrom
remove-ihp-log

Conversation

@mpscholten
Copy link
Copy Markdown
Member

Summary

  • Remove the ihp-log wrapper package entirely (-812 net lines)
  • Use FastLogger (LogStr -> IO ()) from fast-logger directly — no wrapper types, no log levels, no custom formatters
  • FrameworkConfig.logger and ModelContext.logger are now FastLogger directly
  • Query timing optimization uses ModelContext.debugMode :: Bool (from DEBUG env var) instead of checking log level
  • Logger lifecycle managed by withFastLogger bracket in withFrameworkConfig
  • Request logger middleware wired via RequestLogger.Callback logger (perfect type match)
  • buildFrameworkConfig now takes a FastLogger parameter

Motivation

ihp-log wrapped fast-logger with log levels, formatters, and destinations. In practice none of this was used:

  • Everything logged to stdout with the default formatter
  • No custom formatters or non-default destinations anywhere in the codebase
  • Log.fatal and Log.unknown were never called
  • Log level filtering only mattered in one place (query timing skip)

Breaking changes for IHP app developers

  • Log.debug/info/warn/error "msg"?context.logger (toLogStr "msg" <> "\n")
  • import qualified IHP.Log as Logimport System.Log.FastLogger (toLogStr)
  • LogLevel, LoggerSettings, newLogger no longer exist
  • buildFrameworkConfig now requires a FastLogger as first argument

Test plan

  • 398 IDE tests pass
  • All core modules compile (ModelSupport, FrameworkConfig, ErrorController, Job system, WebSocket, AutoRefresh)
  • All external packages compile (ihp-ide, ihp-pglistener, ihp-datasync, ihp-ssc)
  • Zero remaining IHP.Log references in source code
  • CI

🤖 Generated with Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eadbc197be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Log.error ("SSC: Failed parsing action for " <> componentName <> ": " <> errorText)
Log.debug ("SSC: Invalid payload: " <> tshow actionPayload)
log ("SSC: Failed parsing action for " <> componentName <> ": " <> errorText)
log ("SSC: Invalid payload: " <> tshow actionPayload)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid logging raw SSC payloads on parse failures

The new log helper writes every message unconditionally, so this line now emits the full client-supplied actionPayload whenever JSON decoding fails; previously this path used Log.debug and was filtered out in production by default. In production this can leak sensitive user input into centralized logs and lets malformed/probing traffic generate large log volumes, so this payload dump should be debug-gated or removed.

Useful? React with 👍 / 👎.

Comment thread ihp/IHP/Job/Queue/Watch.hs Outdated
poller <- pollForJob enablePollerTriggerRepair pool tableName pollInterval onNewJob
subscription <- liftIO $ pgListener |> PGListener.subscribe (channelName tableNameBS) (const (do
Log.debug ("Received pg_notify for " <> tableName)
?context.logger (toLogStr ("Received pg_notify for " <> tableName) <> "\n")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate pg_notify trace logging behind debug mode

This callback now logs every Postgres notification unconditionally, while the previous code used Log.debug for this message. On busy queues, each enqueued/updated job will produce an extra log write, which can create substantial log noise and I/O overhead in production; this should remain debug-only (or be removed) to avoid degrading throughput and observability signal quality.

Useful? React with 👍 / 👎.

mpscholten and others added 2 commits April 2, 2026 12:04
Replace the ihp-log wrapper package with direct usage of FastLogger
from the fast-logger package. The ihp-log abstraction (log levels,
formatters, destinations) was unused in practice — everything logged
to stdout with the default formatter, and log levels only mattered
for query timing optimization.

Changes:
- FrameworkConfig.logger and ModelContext.logger are now FastLogger
  (LogStr -> IO ()) directly from System.Log.FastLogger
- Add ModelContext.debugMode :: Bool to replace log-level-based query
  timing skip (set from DEBUG env var)
- buildFrameworkConfig takes a FastLogger parameter; withFrameworkConfig
  uses withFastLogger bracket for lifecycle management
- Request logger middleware wired directly via Callback (perfect type
  match with FastLogger)
- All Log.debug/info/warn/error calls replaced with direct
  ?context.logger (toLogStr msg <> "\n")
- Delete ihp-log/ package entirely (-812 net lines)
- Update Guide docs for new logging API

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Append "\n" in buildFrameworkConfig and DevServer logger creation
  instead of at every call site
- Rename ModelContext.debugMode to .queryLoggingEnabled
- Add noopLogger to IHP.ModelSupport.Types, replace ~15 inline
  (\_ -> pure ()) definitions across test files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mpscholten and others added 2 commits April 2, 2026 12:48
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Core Size & Compile Allocations Benchmark

Metric Baseline (master) This PR Change
Core size 11346670 bytes 11348778 bytes 0.0%
Compile allocations 27766636448 bytes 27759991472 bytes -0.0%

Core size within threshold
Compile allocations within threshold

HTTP Latency (GET /, 5000 reqs, 10 concurrent)

Metric Baseline (master) This PR Change
Mean 3.23ms 3.00ms -7.1%
p50 3.10ms 2.90ms
p99 6.50ms 5.40ms
Min 0.80ms 0.70ms
Max 12.90ms 16.70ms
Req/s 3041 3309

HTTP latency within threshold

Top 10 modules (this PR)

Module Size (bytes)
Web.Types.thr 547347
Web.FrontController.thr 428867
Web.Routes.thr 423681
Web.View.Threads.Show.thr 325444
Web.Controller.Threads.thr 322933
Web.Controller.Comments.thr 315622
Web.Controller.Users.thr 284415
Admin.FrontController.thr 276665
Admin.Types.thr 264263
build.Generated.User.thr 259787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant